﻿using Manon.Admin.Web.ApplicationCore.Dtos.Company;
using Manon.Admin.Web.ApplicationCore.Interfaces;
using Manon.Core.IOC;
using Manon.Core.Commons;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Manon.Admin.Web.Controllers
{
    public class CompanyController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }


        /// <summary>
        /// 获取公司信息
        /// </summary>
        /// <returns></returns>
        [Authorize]
        [HttpGet]
        public async Task<GetCompanyInfoOutput> GetCompanyInfo()
        {

            var settingsService = Resolver.GetService<ICompanyService>();
            var result = await settingsService.GetCompanyInfo();

            return result;
        }

        /// <summary>
        /// 保存公司信息
        /// </summary>
        /// <param name="Input"></param>
        /// <returns></returns>
        [Authorize]
        [HttpPost]
        public async Task<Result> SaveCompanyInfo([FromBody] SaveCompanyInfoInput Input)
        {

            var settingsService = Resolver.GetService<ICompanyService>();
            var result = await settingsService.SaveCompanyInfo(Input);

            return result;
        }
    }
}
